﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iOak.Business.Users;

namespace iOak.Web
{
    public partial class UserInfoEdit : BasePage
    {
        private UserService _userService = new UserService();
        private WorkAssistant _workassistant = new WorkAssistant();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            var user = _workassistant.CurrentUser;
            txtEmail.Text = user.Email;
            txtFullName.Text = user.FullName;
            txtMobile.Text = user.Mobile;
            txtPhone.Text = user.Phone;
            lblUserName.Text = user.UserName;
        }

        protected void btnOk_Click(object sender, EventArgs e)
        {
            var user = _workassistant.CurrentUser;
            user.Email = txtEmail.Text;
            user.FullName = txtFullName.Text;
            user.Mobile = txtMobile.Text;
            user.Phone = txtPhone.Text;
            _userService.Update(user);
        }
    }
}